<%--
  Created by IntelliJ IDEA.
  User: admin
  Date: 2016/7/28
  Time: 10:58
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/fmt" prefix="fmt"%>
<!DOCTYPE html>
<html>
<head>
    <meta charset="UTF-8">
    <title>安平代驾</title>
    <link rel="stylesheet" href="../css/login.css" />

</head>
<body>
<section class="login">
    <div class="titulo">安平代驾</div>
    <form id="formControl"  onsubmit = "return checkUser();" >
        <input type="text" name="userAddress" placeholder="您所在的位置" id="locationStr">
        <input type="tel" name="userTel" placeholder="输入手机号" id="telStr" >
        <div class="olvido">
            <div class="">
		        		<span class="required" data-valid="isChecked" data-error="请同意协议" data-type="checkbox">
          				<input type="checkbox" checked="false" id="checkBoxId">
      				</span>

                <a href="../html/xieyi.html">阅读并同意使用协议《安平代驾用户使用协议》</a>

            </div>
        </div>
        <a href="tel:03124668787" class="enviar" onclick="submitClick()">找司机</a>
        <!--		        	<input type="submit" value="找司机" onclick="submitClick()"</input>
        -->			</form>
</section>
<script type="text/javascript" src="/js/jquery-1.11.1.js"></script>
<script type="text/javascript" src="/js/jquery-validate.js"></script>
<script type="text/javascript">
    function submitClick()
    {
        var result = document.getElementById("locationStr").value;
        var resultTel = document.getElementById("telStr").value;
        var resultName = "";
        $.ajax({
            type:"post",
            url:"../user/addUser.do",
            async:true,
            dataType: "json",
            contentType:"application/x-www-form-urlencoded",
            data:{"userAddress":result,"userTel":resultTel},
            success:function(msg){
                console.log(msg)
                alert("数据提交成功");
            },
            error:function(msg){
                alert("数据提交失败");
            }
        });


    }
    function checkUser()
    {
        var result = document.getElementById("locationStr").value;
        if(result== ""){
            alert("请填写位置信息");
            return false;
        }
        var result = document.getElementById("telStr").value;
        if(result== ""){
            alert("请填写位置信息");
            return false;
        }
        if(!$('#checkBoxId').is(':checked')){
            alert("请同意协议");
            return false;
        }
        return true;
        var _status = $(this).validate('submitValidate');
        if(!_status){
            alert("请先同意协议");
        }
    }
    //					$('form').on('submit', function(event) {
    //  						event.preventDefault();
    //  						var _status = $(this).validate('submitValidate'); //return boolean;
    //  						if(!_status){
    //  							alert("请先同意协议");
    //  						}
    //  						Document.getElementById("formControl).Submit();
    //					});
</script>
</body>
</html>

